#include "stdafx.h"
#include "Up.h"
#include "UpDlgEx.h"


BEGIN_MESSAGE_MAP(CUp, CWinApp)
END_MESSAGE_MAP()


CUp::CUp()
{
}

CUp theApp;


BOOL CUp::InitInstance()
{
	WNDCLASS    wndClass;

	::GetClassInfo(AfxGetInstanceHandle(), "#32770", &wndClass);
    wndClass.lpszClassName = CLIENT_UP_CLASS;
    AfxRegisterClass(&wndClass);

	InitCommonControls();
	CWinApp::InitInstance();
	AfxEnableControlContainer();

    HANDLE hMutex = CreateMutex(NULL, TRUE, CLIENT_UP_MUTEX);

	int count = 0;

	while (true)
	{
		if (GetLastError() == ERROR_ALREADY_EXISTS)
		{
			if (count== 3)
			{
				return FALSE;
			}
			else
			{
				count ++;
				Sleep(500);
			}
		}
		else
			break;
	}

	
	CUpDlgEx dlg;
	m_pMainWnd = &dlg;
	dlg.DoModal();

	CloseHandle(hMutex);

	return FALSE;
}
